package com.wuxianbei.wuxianbei.mapper;

import com.wuxianbei.wuxianbei.pojo.Team;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface TeamMapper {

    @Select("select * from team")
    List<Team> all();

    @Delete("delete from team where leader_number =#{leaderNumer}")
    void delete(String leaderNumber);

    @Insert("insert into team(team_name,topic,leader_name,leader_number,leader_phone,leader_major,first_mem_name,first_mem_num,sec_mem_name,sec_mem_num)" +
            "values(#{teamName},#{topic},#{leaderName},#{leaderNumber},#{leaderPhone},#{leaderMajor},#{firstMemName},#{firstMemNum},#{secMemName},#{secMemNum})")
    void insert(Team team);

    @Select("select team_name,topic,leader_name,leader_number,leader_phone,leader_major,first_mem_name,first_mem_num,sec_mem_name,sec_mem_num,check_info from team where leader_number =#{leaderNumber}")
    List<Team> list(String leaderNumber);

    @Select("select team_name,topic,leader_name,leader_number,leader_phone,leader_major,first_mem_name,first_mem_num,sec_mem_name,sec_mem_num,check_info from team where topic =#{topic}")
    List<Team> searchByTopic(String topic);

    @Select("select team_name,topic,leader_name,leader_number,leader_phone,leader_major,first_mem_name,first_mem_num,sec_mem_name,sec_mem_num,check_info from team where team_name =#{teamName}")
    List<Team> searchByTName(String teamName);

    @Select("select team_name,topic,leader_name,leader_number,leader_phone,leader_major,first_mem_name,first_mem_num,sec_mem_name,sec_mem_num,check_info from team where leader_name =#{leaderName}")
    List<Team> searchByLeName(String leaderName);

    @Select("select team_name,topic,leader_name,leader_number,leader_phone,leader_major,first_mem_name,first_mem_num,sec_mem_name,sec_mem_num,check_info from team where leader_number =#{leaderNumber}")
    List<Team> searchByLeNumber(String val);

    @Update("update team set topic = #{topic} where leader_number=#{leaderNumber}")
    void topic(String leaderNumber, String topic);
}
